using System;

namespace Navigant.Model.PreservationNotices
{
	/// <summary>
	/// Static helper class for working with the PreservationNoticeCriteria Enumeration
	/// </summary>
	public class PreservationNoticeCriteriaWorker
	{
		/// <summary>
		/// Returns a dropdown friendly value for a preservation notice criteria
		/// </summary>
		/// <param name="noticeCriteria"></param>
		/// <returns></returns>
		public static string GetDropDownStringRepresentation (PreservationNoticeCriteria noticeCriteria)
		{
			string stringRepresentation = String.Empty;

			switch (noticeCriteria)
			{
				case PreservationNoticeCriteria.All:
					stringRepresentation  = "All";
					break;
				case PreservationNoticeCriteria.Unacknowledged:
					stringRepresentation  = "Unacknowledged";
					break;
				case PreservationNoticeCriteria.UnacknowledgedExternal:
					stringRepresentation  = "Unacknowledged (external only)";
					break;
				case PreservationNoticeCriteria.UnacknowledgedInternal:
					stringRepresentation  = "Unacknowledged (internal only)";
					break;
				case PreservationNoticeCriteria.Undefined:
					throw new OverflowException();
				case PreservationNoticeCriteria.Unsent:
					stringRepresentation  = "Unsent";
					break;
				case PreservationNoticeCriteria.UnsentExternal:
					stringRepresentation  = "Unsent (external only)";
					break;
				case PreservationNoticeCriteria.UnsentInternal:
					stringRepresentation  = "Unsent (internal only)";
					break;
			}

			return stringRepresentation;
		}

	
		/// <summary>
		/// Takes a string and attempts to parse it into a PreservationNoticeCriteria object
		/// </summary>
		/// <param name="noticeCriteriaValue"></param>
		/// <returns></returns>
		public static PreservationNoticeCriteria ParsePreservationNoticeCriteria (string noticeCriteriaValue)
		{
			Type preservationNoticeCriteriaEnumType = typeof(PreservationNoticeCriteria);

			if (Enum.IsDefined(preservationNoticeCriteriaEnumType, noticeCriteriaValue))
			{
				return (PreservationNoticeCriteria)Enum.Parse(typeof(PreservationNoticeCriteria), noticeCriteriaValue, true);
			}

			return PreservationNoticeCriteria.Undefined;
		}

        /* Date : 06-Aug-08
         * Developer : Rajul Patel */
        /// <summary>
        /// Returns a list friendly value for a preservation notice criteria
        /// </summary>
        /// <param name="noticeCriteria"></param>
        /// <returns></returns>
        public static string GetListStringRepresentation(bool isInternalCustodian, bool isAcknowledged)
        {
            string stringRepresentation = String.Empty;

            stringRepresentation = isInternalCustodian ? "Internal" : "External";
            stringRepresentation += ", ";
            stringRepresentation += isAcknowledged ? "Acknowledged" : "Unacknowledged";

            return stringRepresentation;
        }
	}
}
